import 'package:flutter/material.dart';
import 'package:metaera_flutter/utils/Device.dart';
import 'package:metaera_flutter/utils/Font.dart';
import 'package:metaera_flutter/utils/Color.dart';

class NavigationView extends StatelessWidget implements PreferredSizeWidget {
  final String title;
  final List<Widget>? actions;
  final String? type;

  const NavigationView({
    super.key,
    required this.title,
    this.actions,
    this.type,
  });

  @override
  Widget build(BuildContext context) {
    return AppBar(
      title: Text(
        title,
        style: TextStyle(
          color: AppColors.color333,
          fontSize: AppFonts.fontSize18,
          fontWeight: FontWeight.bold,
        ),
      ),
      // 当 type 不为 'home' 时显示返回按钮
      leading: type == 'home'
          ? null
          : IconButton(
              icon: Image.asset(
                'assets/images/base/back.png',
                width: 20,
                height: 20,
              ),
              onPressed: () {
                Navigator.pop(context);
              },
            ),
      actions: [if (actions != null) ...actions!],
    );
  }

  @override
  Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}
